<!--  -->
<template>
<div>
    <mt-header title="生成订单(地址为默认地址)">
  <router-link  to  slot="left">
    <mt-button icon="back" @click="$router.back(-1)"></mt-button>
  </router-link>
  <mt-button icon="more" slot="right"></mt-button>
    </mt-header>
  
<div class="border">
        <div class="content">
            <div class="text">
              <div>
                <p>{{ data.Name }}</p>
                <p>{{ data.Phone }}</p>
              </div>
              <div>
                  <p>{{ data.Province }}</p>
                  <p>{{ data.city }}</p>
                  <p>{{ data.District }}</p>
                  <p>{{ data.AdressDetail }}</p>
              </div>
            </div>
        </div>
</div>
<div class="ordersum">
    <div class="order" v-for="item in this.shop" :key="item.Ooid">
                        <div class="img">
                          <img :src="require(`../assets/img/product/${item.Img}`)" alt="">
                    </div>
                    <div class="text">
                        <p>{{ item.title }} </p>
                        <div class="time">
                            <span>￥{{ item.price }}</span>
                            <span>x{{ item.Sum }}</span>
                        </div>
                    </div>
                   
                </div>
</div>
<van-popup v-model="show" position="bottom" :style="{ height: '20%' }" >
                <p id="butt2" @click="setStatuu()">支付宝支付</p>
                <p id="butt3" @click="setStatuu()">微信支付</p>
            </van-popup>
<div class="foot">
    <div class="price">
      <p>商品金额</p>
      <p>￥{{ sum }}</p>
    </div>
    <div class="but" @click="set()">
      <p>确认下单</p>
    </div>
</div>
</div>
</template>

<script>
import { Toast } from 'vant';
export default {
data() {
return {
    data:"",
    oid:'',
    sum:0,
    shop:"",
    show:false
}
},
//生命周期 - 创建完成（访问当前this实例）
created() {

},
//生命周期 - 挂载完成（访问DOM元素）
mounted() {
  // 判断登录状态
  let userInfo=JSON.parse(localStorage.getItem("userInfo")); //去除localStoreage中的登录状态
        this.getdata(userInfo.uid)
  this.oid=this.$route.params.oid
  console.log("传入",this.oid)  
  this.getshops()
},
methods:{
    getdata(uid){
        //获取默认地址
        var url= `/GetUserIsAdress?uid=${uid}&IsAdress=0`
          // console.log(url)
          this.axios.get(url).then(res=>{
            console.log(res)
            this.data=res.data.result[0]
            console.log(this.data)
          })
    },
    getshops(){
       //获取下单商品
       var url= `/GetOrderShop?oid=${this.oid}`
          // console.log(url)
          this.axios.get(url).then(res=>{
            console.log(res)
            this.shop=res.data.result
            // console.log(this.shop.length)

            for (let i = 0; i < this.shop.length; i++) {
              // console.log(this.shop[i].price)
                  this.sum=this.sum+this.shop[i].price*1

            }
            // console.log(this.sum)
          })
    },
    setStatuu(){
      var url=`/SetOrderDetails?oid=${this.oid}`
     this.axios.get(url).then(res=>{
            console.log(res)
            Toast.success('支付成功');
            this.$router.push("/ShoppingCart")
    })
    },
    set(){
      this.show=true
    }
}
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.mint-header{
    color: black;
    background-color: white;
    font-size: 10px;
}

.border{
      margin: 20px 10px;
      margin-bottom: 20px;
      border-bottom: 1px solid #e0e0e0 ;
    }
    .border .content{
      display: flex;
      padding-bottom: 20px;
    }
    .border .text {
      display: inline-block;
      /* background-color: aqua; */
      width: 80%;
      /* height: 0px; */
      font-size: 10px;
      padding-left: 20px;
    }
    .border .text p{
      display: inline-block;
      padding: 4px;

    }
    .border .butt{
      width: 20%;
      /* background-color: rgb(28, 172, 90); */
      text-align: center;
      position: relative;
    }
    .border .butt img{
      width: 18px;
      height: 18px;
      /* text-align: center; */
      position: absolute;
      left: 50%;
      top: 50%;
      transform:translate(-50%,-50%);
    }


.ordersum{
      border-bottom: 1px solid #e0e0e0 ;

}
    .order{
    display: flex;
    font-size: 12px;
    height: 80px;
    /* border-top: 1px solid rgb(224, 224, 224); */
    /* border-bottom: 1px solid rgb(224, 224, 224);   */
}
.order .img{
    width:30%;
}
.order img{
    width: 100%;
    height: 100%;
}
.order .text{
    width: 70%;
    margin-top: 10px;
    /* margin-top: 5px; */
}
.order .text p{
    margin-top: 3px;
}
.order .text .time{
    margin-top: 15px;
}
.order .text p:nth-child(2){
    /* margin-top: 10px; */
    color: rgb(100, 101, 102);
    /* color: aqua; */
}

.order .price{
    width: 25%;
    text-align: center;
}
.order .price p{
    margin-top: 10px;
    font-size: 15px;
    margin-left: 20px;
    /* align-items: center; */

} 
.order .price :nth-child(2){
    margin-top: 5px;
    font-size: 15px;
    margin-left: 50px;
    /* color: aqua; */
    /* align-items: center; */
} 


.time span:first-child{
    font-size: 12px;
    margin-left: 10px;
    color: red;
}
.time span:last-child{
    font-size: 12px;
    margin-left: 10px;
    float: right;
    margin-right: 30px;
}

.foot .price{
  width: 100%;
  display: flex;
  line-height: 20px;
  font-size: 15px;
  position:fixed;
  bottom: 60px;
}
.foot .price:first-child{
  margin-left: 20px;
}
.foot .price p:nth-child(2){
  color: red;
  margin-left: 50%;
}
.foot .but{
    text-align: center;
    margin-left: 5%;
    color: white;
    width: 90%;
    position: fixed;
    line-height: 40px;
    bottom: 10px;
    background-color: rgb(27, 174, 174);
}


#butt2,#butt3{
    margin-top: 15px;
    width: 80%;
    margin-left: 10%;
    line-height: 40px;
    color: white;
    text-align: center;
    background-color: aquamarine
}
#butt2{
    background-color: rgb(25, 137, 250);
}
#butt3{
    background-color: rgb(79, 172, 141);
} 
</style>